using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class DamageReceiver : CoreComponent, IDamageable
{
    //private CollisionSenses collisionSenses;

    //private Movement movement;

    //private Stats stats;

    //private ParticleManager particleManager;

    //public CollisionSenses CollisionSenses { get => collisionSenses ?? core.GetCoreComponent<CollisionSenses>(ref collisionSenses); }
    //protected Movement Movement { get => movement ?? core.GetCoreComponent<Movement>(ref movement); }
    //public Stats Stats { get => stats ?? core.GetCoreComponent<Stats>(ref stats); }
    //public ParticleManager ParticleManager { get => particleManager ?? core.GetCoreComponent<ParticleManager>(ref particleManager); }

    [SerializeField]
    private GameObject damageParticles;

    private CoreComp<Stats> stats;

    private CoreComp<ParticleManager> particleManager;

    public void Damage(float amount)
    {
        Debug.Log(core.transform.parent.name + "Damaged");
        stats.Comp.DecreaseHealth(amount);
        particleManager.Comp?.StartParticlesWithRandomRotation(damageParticles);
    }

    protected override void Awake()
    {
        base.Awake();

        stats = new CoreComp<Stats>(core);
        particleManager = new CoreComp<ParticleManager>(core);
    }
}

